<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="参数">
              <a-input v-model="queryParam.key"></a-input>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <div class="table-operator">
    </div>

    <div>
      <a-button @click="handlequery" type="primary" icon="plus">查询</a-button>
      <j-vxe-table keep-source :ref="keyresult" :loading="loading" :columns="columns" :dataSource="dataSource"
        :maxHeight="500" :disabled="formDisabled" :rowNumber="true" :rowSelection="true" :bordered="true" :toolbar="true"
        :alwaysEdit="true" @valueChange="handleValueChange" @afterPushRow="afterPushRows"
        @edit-actived="handleAfterValueChange">
      </j-vxe-table>
    </div>

  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
import { JVXETypes } from '@/components/jeecg/JVxeTable'
import { getAction } from '../../../../api/manage'

export default {
  name: 'MvperiodList',
  mixins: [JVxeTableModelMixin],
  components: {

  },
  data () {
    return {
      description: '参数列表',
      dataSource: [],
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '参数分区',
          align: "center",
          key: 'keyarea',
          type: JVXETypes.input
        },
        {
          title: '参数名',
          align: 'center',
          key: 'key',
          type: JVXETypes.input,
        },
        {
          title: '参数值',
          align: 'center',
          dataIndex: 'keyvalue',
          type: JVXEType.sel_search,
          dictOptions: {

          }
        },
        {
          title: '参数备注',
          align: "center",
          dataIndex: 'keyremarks',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      ipagination: {
        current: 1,
        pageSize: 12,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      url: {
        list: "/base/imperiod/list",
        addperiod: '/base/imperiod/addperiod',
        delete: "/base/imperiod/delete",
        deleteBatch: "/base/imperiod/deleteBatch",
        exportXlsUrl: "/base/imperiod/exportXls",
        importExcelUrl: "base/imperiod/importExcel",
        opernurl: '/base/imperiod/changeperiodstate',
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created () {
    this.getSuperFieldList();
  },
  mounted () {
    this.dataSource = [];
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    handleOpen (record) {
      let companyid = this.queryParam.companyid;
      if (companyid === undefined || companyid === '') {
        this.$message.error("请先选择公司");
        return;
      }
      let periodstate = 'open';
      let perioddate = record.perioddate;
      let parmas = { companyid: companyid, perioddate: perioddate, periodstate: periodstate };
      let that = this;
      getAction(this.url.opernurl, parmas).then(res => {
        if (res.success) {
          that.loadData();
          this.$message.success("打开成功");
        } else {
          this.$message.error(res.message);
        }
      })
    },
    handlequery () {
      if (this.queryParam.companyid === undefined || this.queryParam.companyid === '') {
        this.$message.error("请先选择公司");
        return;
      }
      getAction(this.url.addperiod, { companyid: this.queryParam.companyid }).then(res => {
        if (res.success) {
          //this.$message.success("查询成功");
        }
      })
      this.loadData();
    },
    initDictConfig () {
    },
    getSuperFieldList () {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'companyid', text: '公司', dictCode: '' })
      fieldList.push({ type: 'date', value: 'fromdate', text: '期间从' })
      fieldList.push({ type: 'date', value: 'enddate', text: '期间止' })
      fieldList.push({ type: 'string', value: 'periodstate', text: '期间状态', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>